﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucQuanLyMenu.ascx.cs"
    Inherits="STT.Admin.UserControls.ucQuanLyMenu" %>

<%--<div id="content-header">
    <div id="breadcrumb">
        <a href="../Default.aspx" class="tip-bottom" data-original-title="Về bảng điều khiển">
            <i class="icon-home"></i>Trang chủ
        </a>
        <a href="../Admin/Default.aspx?" class="current">Quản lý hệ thống</a>
        <a href="../Admin/Default.aspx?" class="current">Quản lý Danh mục chức năng</a>
    </div>
</div>--%>

<div class="widget-box">
    <div class="widget-title">
        <span class="icon"><i class="icon-th"></i></span>
        <h5 runat="server" id="txtTieuDe">Danh sách danh mục chức năng</h5>

        <div id="search">
            <asp:TextBox ID="txtTimKiem" runat="server" placeholder="Nhập từ tìm kiếm..."></asp:TextBox>
            <button class="tip-left" data-original-title="Tìm kiếm">
                <asp:ImageButton ID="btSearch" runat="server" ImageUrl="~/img/icon-search.png" OnClick="btSearch_Click" />
            </button>
        </div>
    </div>

    <div class="widget-content nopadding">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
            <asp:GridView ID="gvDMChucNang" runat="server" CssClass="table table-bordered table-hover"
                AutoGenerateColumns="False" DataKeyNames="MaCN,MaCNCha,TrangThai"
                OnRowCommand="gvDMChucNang_RowCommand"
                EnableViewState="False" OnPageIndexChanging="gvDMChucNang_PageIndexChanging"
                OnRowDeleting="gvDMChucNang_RowDeleting"
                AllowPaging="True" PageSize="15">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="cbChonTat" runat="server" onclick="cbChonTat(this);" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="cbChon" runat="server" onclick="cbChon(this);" />
                        </ItemTemplate>
                        <ItemStyle Width="10px" HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
                    <asp:BoundField DataField="MaCN" HeaderText="Mã chức năng"
                        InsertVisible="False" ReadOnly="True" SortExpression="MaCN"
                        ItemStyle-CssClass="span1" Visible="False">
                        <ItemStyle CssClass="span1"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="TenCN" HeaderText="Tên chức năng"
                        SortExpression="TenCN" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="Link" HeaderText="Liên kết"
                        SortExpression="Link" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="TenCNCha" HeaderText="Chức năng cha"
                        SortExpression="TenCNCha" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="Anh" HeaderText="Ảnh"
                        SortExpression="Sdt" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>

                    <asp:TemplateField HeaderText="Sửa" ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
                                Text="Sửa" CommandName="ChonSua" CommandArgument="<%#((GridViewRow)Container).RowIndex%>">
                                <img src="../../img/edit.jpg" alt="Alternate Text" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Xóa" ShowHeader="False">
                        <ItemTemplate>
                            <%-- Bắt sự kiện nhấn nút xóa --%>
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" OnClientClick="return ConfirmDelete('Có chắc bạn muốn xóa?');">
                                <img src="../../img/delete.jpg" alt="Alternate Text" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

            <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl">

                <asp:LinkButton ID="lbXoaTat" runat="server" CssClass="btn" OnClientClick="return ConfirmDelete('Có chắc bạn muốn xóa các dòng đã chọn?');"
                    OnClick="lbXoaTat_Click">Xóa chọn</asp:LinkButton>

                <div class="btn-group">
                    <a href="#thongTin" data-toggle="modal" id="btThem">
                        <button class="btn">
                            Thêm mới</button>
                    </a>
                    <button data-toggle="dropdown" class="btn dropdown-toggle">
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#themFileExcel" data-toggle="modal">Thêm từ file Excel</a></li>
                        <%--<li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>--%>
                    </ul>
                </div>

                <%--<div class="btn-group">
                    <button class="btn">
                        <asp:LinkButton ID="lbXuatDuLieu" runat="server" OnClick="lbXuatDuLieu_Click">Xuất dữ liệu</asp:LinkButton>
                    </button>
                    <button data-toggle="dropdown" class="btn dropdown-toggle">
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#">Xuất Excel</a></li>
                        <li><a href="#">Xuất Word</a></li>
                        <li><a href="#">Xuất PDF</a></li>
                    </ul>
                </div>--%>
            </div>
        </div>
    </div>
</div>

<div id="validationcontrol">
    <div id="thongTin" class="modal hide" aria-hidden="true" style="display: none;">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h3>Thêm danh mục chức năng</h3>
        </div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label">Tên chức năng: </label>
                <div class="controls">
                    <asp:TextBox ID="txtTenCN" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" ErrorMessage="(*)" ControlToValidate="txtTenCN"
                        ForeColor="Red" ToolTip="Bạn chưa nhập tên đơn vị!" ValidationGroup="error"
                        runat="server" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Liên kết: </label>
                <div class="controls">
                    <asp:TextBox ID="txtLienKet" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ErrorMessage="(*)" ControlToValidate="txtLienKet"
                        ForeColor="Red" ToolTip="Bạn chưa chọn cấp!" ValidationGroup="error"
                        runat="server" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Mô tả: </label>
                <div class="controls">
                    <asp:TextBox ID="txtMoTa" runat="server"></asp:TextBox>
                    <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="(*)" ControlToValidate="txtDiaChi"
                        ForeColor="Red" ToolTip="Bạn chưa nhập địa chỉ!" ValidationGroup="error"
                        runat="server" />--%>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Chức năng cha: </label>
                <div class="controls">
                    <asp:DropDownList ID="ddChucNangCha" runat="server"></asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="(*)" ControlToValidate="ddChucNangCha"
                        InitialValue="-1" ForeColor="Red" ToolTip="Bạn chưa chọn chức năng cha!" ValidationGroup="error"
                        runat="server" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Trạng thái: </label>
                <div class="controls">
                    <asp:DropDownList ID="ddTrangThai" runat="server">
                        <asp:ListItem Text="Chọn trạng thái" Value="-1"></asp:ListItem>
                        <asp:ListItem Text="Sử dụng" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Không sử dụng" Value="0"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ErrorMessage="(*)" ControlToValidate="ddTrangThai"
                        InitialValue="-1" ForeColor="Red" ToolTip="Bạn chưa chọn  trạng thái!" ValidationGroup="error"
                        runat="server" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Tên ảnh: </label>
                <div class="controls">
                    <asp:TextBox ID="txtTenAnh" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ErrorMessage="(*)" ControlToValidate="txtTenAnh"
                        ForeColor="Red" ToolTip="Bạn chưa chọn  trạng thái!" ValidationGroup="error"
                        runat="server" />
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <asp:Button ID="btThemMoi" runat="server" CssClass="btn btn-primary" Text="Thêm mới"
                OnClick="btThemMoi_Click" CausesValidation="true" ValidationGroup="error" />
            <asp:Button ID="btSua" runat="server" CssClass="btn btn-primary btValidate" Text="Lưu"
                OnClick="btSua_Click" CausesValidation="true" ValidationGroup="error" />
            <a data-dismiss="modal" class="btn" href="#">Hủy</a>
        </div>
    </div>
</div>
<asp:HiddenField ID="hfMaDonVi" runat="server" />
<div id="themFileExcel" class="modal hide" aria-hidden="true" style="display: none;">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">×</button>
        <h3 runat="server" id="H1">Thêm từ file Excel</h3>
    </div>
    <div class="modal-body">
        <asp:FileUpload ID="FileUpload" runat="server" />
    </div>
    <div class="modal-footer">
        <asp:Button ID="btThemExcel" runat="server" CssClass="btn btn-primary" Text="Thêm từ file"
            OnClick="btThemExcel_Click" CausesValidation="false" />
        <a data-dismiss="modal" class="btn" href="#">Hủy</a>
    </div>
</div>
<script>

    $(document).ready(function () {

        if ('<%Response.Write(chonSuaClick.ToString());%>' == 'True') {
            $('#btThem').click();
            $('#<%=btThemMoi.ClientID%>').css('display', 'none');
            $('#<%=btSua.ClientID%>').css('display', 'inline-block');
        }

        $('#btThem').click(function () {
            $('#thongTin').find('input:not([type=submit])').val('');
            $('#<%=btThemMoi.ClientID%>').css('display', 'inline-block');
            $('#<%=btSua.ClientID%>').css('display', 'none');
        });
    });
</script>
